]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
calendar-server: Modernize GObject usage
authorFlorian Müllner <fmuellner@gnome.org>
Thu, 24 Sep 2015 16:43:24 +0000 (18:43 +0200)
committerFlorian Müllner <fmuellner@gnome.org>
Thu, 15 Oct 2015 19:04:07 +0000 (21:04 +0200)
src/calendar-server/calendar-sources.c
src/calendar-server/calendar-sources.h

index 1d691b22f8b05c7aefd1843e05a5efd46f727c0c..628f89b070d629d1af08c805afa801fb5beb23f2 100644 (file)
@@ -41,8 +41,6 @@
 #define N_(x) x
 #endif
 
-#define CALENDAR_SOURCES_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CALENDAR_TYPE_SOURCES, CalendarSourcesPrivate))
-
 typedef struct _ClientData ClientData;
 typedef struct _CalendarSourceData CalendarSourceData;
 
@@ -66,6 +64,14 @@ struct _CalendarSourceData
   guint            loaded : 1;
 };
 
+typedef struct _CalendarSourcesPrivate CalendarSourcesPrivate;
+
+struct _CalendarSources
+{
+  GObject                 parent;
+  CalendarSourcesPrivate *priv;
+};
+
 struct _CalendarSourcesPrivate
 {
   ESourceRegistry    *registry;
@@ -77,8 +83,8 @@ struct _CalendarSourcesPrivate
   CalendarSourceData  task_sources;
 };
 
-static void calendar_sources_class_init (CalendarSourcesClass *klass);
-static void calendar_sources_init       (CalendarSources      *sources);
+G_DEFINE_TYPE_WITH_PRIVATE (CalendarSources, calendar_sources, G_TYPE_OBJECT)
+
 static void calendar_sources_finalize   (GObject             *object);
 
 static void backend_died_cb (EClient *client, CalendarSourceData *source_data);
@@ -108,34 +114,6 @@ client_data_free (ClientData *data)
   g_slice_free (ClientData, data);
 }
 
-GType
-calendar_sources_get_type (void)
-{
-  static GType sources_type = 0;
-  
-  if (!sources_type)
-    {
-      static const GTypeInfo sources_info =
-      {
-       sizeof (CalendarSourcesClass),
-       NULL,           /* base_init */
-       NULL,           /* base_finalize */
-       (GClassInitFunc) calendar_sources_class_init,
-       NULL,           /* class_finalize */
-       NULL,           /* class_data */
-       sizeof (CalendarSources),
-       0,              /* n_preallocs */
-       (GInstanceInitFunc) calendar_sources_init,
-      };
-      
-      sources_type = g_type_register_static (G_TYPE_OBJECT,
-                                            "CalendarSources",
-                                            &sources_info, 0);
-    }
-  
-  return sources_type;
-}
-
 static void
 calendar_sources_class_init (CalendarSourcesClass *klass)
 {
@@ -145,14 +123,11 @@ calendar_sources_class_init (CalendarSourcesClass *klass)
 
   gobject_class->finalize = calendar_sources_finalize;
 
-  g_type_class_add_private (klass, sizeof (CalendarSourcesPrivate));
-
   signals [APPOINTMENT_SOURCES_CHANGED] =
     g_signal_new ("appointment-sources-changed",
                  G_TYPE_FROM_CLASS (gobject_class),
                  G_SIGNAL_RUN_LAST,
-                 G_STRUCT_OFFSET (CalendarSourcesClass,
-                                  appointment_sources_changed),
+                 0,
                  NULL,
                  NULL,
                   NULL,
@@ -163,8 +138,7 @@ calendar_sources_class_init (CalendarSourcesClass *klass)
     g_signal_new ("task-sources-changed",
                  G_TYPE_FROM_CLASS (gobject_class),
                  G_SIGNAL_RUN_LAST,
-                 G_STRUCT_OFFSET (CalendarSourcesClass,
-                                  task_sources_changed),
+                 0,
                  NULL,
                  NULL,
                   NULL,
@@ -179,7 +153,7 @@ calendar_sources_init (CalendarSources *sources)
   GDBusConnection *session_bus;
   GVariant *result;
 
-  sources->priv = CALENDAR_SOURCES_GET_PRIVATE (sources);
+  sources->priv = calendar_sources_get_instance_private (sources);
 
   /* WORKAROUND: the hardcoded timeout for e_source_registry_new_sync()
      (and other library calls that eventually call g_dbus_proxy_new[_sync]())
index 759f5bd856dd1f1259763b156e6d7f8451cd6d11..d11850fff0878abc9716a5696a42fda1c00045b3 100644 (file)
 
 G_BEGIN_DECLS
 
-#define CALENDAR_TYPE_SOURCES        (calendar_sources_get_type ())
-#define CALENDAR_SOURCES(o)          (G_TYPE_CHECK_INSTANCE_CAST ((o), CALENDAR_TYPE_SOURCES, CalendarSources))
-#define CALENDAR_SOURCES_CLASS(k)    (G_TYPE_CHECK_CLASS_CAST ((k), CALENDAR_TYPE_SOURCES, CalendarSourcesClass))
-#define CALENDAR_IS_SOURCES(o)       (G_TYPE_CHECK_INSTANCE_TYPE ((o), CALENDAR_TYPE_SOURCES))
-#define CALENDAR_IS_SOURCES_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), CALENDAR_TYPE_SOURCES))
-#define CALENDAR_SOURCES_GET_CLASS(o)(G_TYPE_INSTANCE_GET_CLASS ((o), CALENDAR_TYPE_SOURCES, CalendarSourcesClass))
+#define CALENDAR_TYPE_SOURCES (calendar_sources_get_type ())
+G_DECLARE_FINAL_TYPE (CalendarSources, calendar_sources,
+                      CALENDAR, SOURCES, GObject)
 
-typedef struct _CalendarSources        CalendarSources;
-typedef struct _CalendarSourcesClass   CalendarSourcesClass;
-typedef struct _CalendarSourcesPrivate CalendarSourcesPrivate;
-
-struct _CalendarSources
-{
-  GObject                 parent;
-  CalendarSourcesPrivate *priv;
-};
-
-struct _CalendarSourcesClass
-{
-  GObjectClass    parent_class;
-
-  void         (* appointment_sources_changed) (CalendarSources *sources);
-  void         (* task_sources_changed)        (CalendarSources *sources);
-};
-
-
-GType            calendar_sources_get_type                (void) G_GNUC_CONST;
 CalendarSources *calendar_sources_get                     (void);
 GList           *calendar_sources_get_appointment_clients (CalendarSources *sources);
 GList           *calendar_sources_get_task_clients        (CalendarSources *sources);